package com.maila.calltaxi_driver.adapter;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseExpandableListAdapter;
import android.widget.TextView;

import com.maila.calltaxi_driver.R;
import com.zhy.autolayout.utils.AutoUtils;

import butterknife.BindView;
import butterknife.ButterKnife;

/**
 * Created by Administrator on 2017/7/7.
 */

public class AllOrderRecordAdapter extends BaseExpandableListAdapter {

    Context context;

    public AllOrderRecordAdapter(Context context) {
        this.context = context;
    }

    @Override
    public int getGroupCount() {
        return 12;
    }

    @Override
    public int getChildrenCount(int groupPosition) {
        return 12;
    }

    @Override
    public Object getGroup(int groupPosition) {
        return null;
    }

    @Override
    public Object getChild(int groupPosition, int childPosition) {
        return null;
    }

    @Override
    public long getGroupId(int groupPosition) {
        return 0;
    }

    @Override
    public long getChildId(int groupPosition, int childPosition) {
        return 0;
    }

    @Override
    public boolean hasStableIds() {
        return false;
    }

    @Override
    public View getGroupView(int groupPosition, boolean isExpanded, View convertView, ViewGroup parent) {
        GroupHolder groupHolder = null;
        if (convertView == null) {
            convertView = LayoutInflater.from(context).inflate(R.layout.item_head_orderecode, parent, false);
            groupHolder = new GroupHolder(convertView);
            convertView.setTag(groupHolder);
            AutoUtils.autoSize(convertView);
        } else {
            groupHolder = (GroupHolder) convertView.getTag();
       }
        groupHolder.tvTime.setText("2017-"+(groupPosition+1));
        return convertView;
    }

    @Override
    public View getChildView(int groupPosition, int childPosition, boolean isLastChild, View convertView, ViewGroup parent) {
        ChildHolder childHolder = null;
        if (convertView == null) {
            convertView = LayoutInflater.from(context).inflate(R.layout.item_order_recode, parent, false);
            childHolder = new ChildHolder(convertView);
            convertView.setTag(childHolder);
            AutoUtils.autoSize(convertView);
        } else {
            childHolder = (ChildHolder) convertView.getTag();
        }
//        ImgLoadUtils.loadImg(context,childHolder.iv_goods_photo,BASE_URL+dataBeen.get(i).getContent().get(i1).getGoods_thumb());
//        childHolder.tv_goods_name.setText(dataBeen.get(i).getContent().get(i1).getGoods_name());
//        childHolder.tv_money.setText(dataBeen.get(i).getContent().get(i1).getIntegral()+"买豆");
        return convertView;
    }

    @Override
    public boolean isChildSelectable(int groupPosition, int childPosition) {
        return false;
    }

    static class GroupHolder {
        @BindView(R.id.tv_time)
        TextView tvTime;

        GroupHolder(View view) {
            ButterKnife.bind(this, view);
        }
    }

    static class ChildHolder {
        @BindView(R.id.tv_data)
        TextView tvData;
        @BindView(R.id.tv_time)
        TextView tvTime;
        @BindView(R.id.tv_money)
        TextView tvMoney;
        @BindView(R.id.tv_details)
        TextView tvDetails;

        ChildHolder(View view) {
            ButterKnife.bind(this, view);
        }
    }
}
